package com.community.controller;

import com.community.base.BaseController;
import com.community.common.Const;
import com.community.common.ServerResponse;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 回答操作控制层
 */
@RestController
@RequestMapping("/answerOperationController/")
@CrossOrigin(origins = Const.REQUESTURL,maxAge = 3600,allowCredentials = "true")
public class AnswerOperationController extends BaseController {

    /**
     * 对答案进行对应操作
     * @param aid
     * @param type
     * @param userName
     * @param request
     * @return
     */
    @PostMapping("operation.do")
    public ServerResponse<String> operation(@RequestParam(value = "aid") int aid,
                                            @RequestParam(value = "type") int type,
                                            @RequestParam(value = "userName") String userName,
                                            HttpServletRequest request){
        return iAnswerOperationService.operation(aid,type,userName,request);
    }

    /**
     * 查询答案点赞数目
     * @param aid
     * @param force
     * @return
     */
    @GetMapping("countNumByAid.do")
    public ServerResponse<Integer> countNumByAid(@RequestParam(value = "aid") int aid,
                                                 @RequestParam(value = "force") int force){
        return iAnswerOperationService.countNumByAid(aid,force);
    }
}
